@include('admin::layouts.header')
<div class="admin-main layui-anim layui-anim-upbit">
	<fieldset class="layui-elem-field layui-field-title">
		<legend>添加</legend>
	</fieldset>
	<form class="layui-form layui-form-pane" lay-filter="form">
		<div class="layui-form-item">
            <label class="layui-form-label">商品分类</label>
            <div class="layui-input-4">
                <select lay-verify="required" lay-search="" lay-filter="one_list">
                    <option value="">请选择</option>
					@foreach($product_type_info as $v)
					<option value="{{$v->id}}">{{$v->lefthtml}}{{$v->title}}</option>
					@endforeach
                </select>
            </div>
        </div>
		<div class="layui-form-item">
            <label class="layui-form-label">所属属性</label>
            <div class="layui-input-4">
                <select name="attrbute_key_id" id="attrbute_key_id" lay-verify="required" lay-search="">
                    <option value="">请选择</option>
                </select>
            </div>
        </div>
		<div class="layui-form-item">
            <label class="layui-form-label">属性值</label>
            <div class="layui-input-4">
                <input type="text" maxlength="30" name="value" lay-verify="required" placeholder="请输入属性名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-2">
                <input type="text" onkeyup="this.value=this.value.replace(/\D/gi,&quot;&quot;)" maxlength="11" name="sort" value="1" placeholder="请输入排序编号" lay-verify="required" class="layui-input">
            </div>
        </div>
		@include('admin::layouts.submit',['url'=>route('shop_admin.product_attrbute_value.index')])
	</form>
</div>
@include('admin::layouts.footer')
@include('admin::layouts.create_ajax',['url'=>route('shop_admin.product_attrbute_value.store')])
<script>
    layui.use(['form','layer'], function () {
        var form = layui.form,layer = layui.layer,$= layui.jquery;
        form.on('select(one_list)', function(data){
			var product_type_id = data.value;
			var loading = layer.load(1, {shade: [0.1, '#fff']});
			$.get("/shop_admin/product_attrbute_value/"+product_type_id+"/attrbute_key", function (data) {
				layer.close(loading);
				var html='<option value="">请选择</option>';
				$.each(data, function (i, value) {
					html += '<option value="number:'+value.id+'">'+value.name+'</option>';
				});
				$('#attrbute_key_id').html(html);
				form.render();
			});
        });
    });
</script>